<?php
	
	class GP_page_index extends GP_controleur
	{
		var $controleur;
		var $db;
		
		function __construct()
		{
			global $page;
			$this -> controleur = parent::getInstance($page);
		}
		
		function get_products()
		{
			$requete = "SELECT id, id_line, name, num_image, alt_index FROM _fo_products ORDER BY id_line, ordre";
			return call_sql_cache($requete);
		}
		
		function afficher()
		{			
			global $page, $urirw;
			
			// si url rewrite
			if (strlen($urirw))
			{
				$pagerw = fakeurl($urirw);
				$htmltmp = $this -> controleur -> htmlrw('header');
				$htmltmp .= $this -> controleur -> htmlrw($page);
				$htmltmp .= $this -> controleur -> htmlrw('footer');
				savefile($pagerw, $htmltmp);
				if (!IS_IE)
					header("HTTP/1.1 301 Moved Permanently");
				include($urirw);
			}
			else
			{
				$this -> controleur -> add_html('header');
				$this -> controleur -> add_html($page);
				$this -> controleur -> add_html('footer');
			}
		}
		
		function setvar($var, $val)
		{
			global $urirw;
			if (strlen($urirw))
				$this -> $var = $val;
			else
				$this -> controleur -> $var = $val;
		}
	}
	
	$page_index = new GP_page_index;
	$page_index -> db = GP_db::getInstance(BDD_DSN, BDD_UTILISATEUR, BDD_MOT_DE_PASSE);
	$page_index -> setvar('titre', 'Perfumes and fragrances for men and women on Comme des Garcons website');
	$page_index -> setvar('meta_description', 'The official website of the unconventional label Comme des Garcons displaying the original perfumes and fragrances for men and women (unisex) made by talented creators.');
	$page_index -> setvar('meta_keywords', 'fragrance, perfume for women, men perfume, perfume on line, new perfume, comme des garcons website');
	$page_index -> setvar('products', $page_index -> get_products());
	$page_index -> afficher();
?>